package com.kingwang.training.designpattern.srp.service.impl;

import com.kingwang.training.designpattern.srp.bo.srp.ConnectionManager;
import com.kingwang.training.designpattern.srp.bo.srp.OpticalModem;
import com.kingwang.training.designpattern.srp.service.ConnectionService;
import org.springframework.stereotype.Service;

@Service
public class ConnectionServiceImpl implements ConnectionService {
    @Override
    public void dial() {
        ConnectionManager connectionManager = getConnectionManager();

        connectionManager.dial("username", "pwd");
    }

    @Override
    public void hangup() {
        ConnectionManager connectionManager = getConnectionManager();

        connectionManager.hangup();
    }

    private ConnectionManager getConnectionManager() {
        return new OpticalModem();
    }
}
